﻿<?php
    include('checkAdminAccess.php');
    $iniVars = parse_ini_file('../../config.ini',TRUE);
    include('../classes/adodb5/adodb.inc.php');
    include('../classes/class.upload.php');
    include('../function/db.func.php');
    
    $sql = 'UPDATE text_data SET td_value="'.addslashes($_POST['editor']).'" WHERE td_id=1';
    $result = $db->Execute($sql);
    if($result)
    {
        $error = FALSE;
        $msg = "<br />แก้ไขข้อมูลเรียบร้อยแล้ว";
    }
    else
    {
        $error = TRUE;
        $msg = "<br />ไม่สามารถแก้ไขข้อมูลได้ กรุณาลองใหม่อีกครั้ง.";
    }
    
    
     if($error)
    {
         echo <<<js
        <script src="{$iniVars['Locations']['siteurl']}js/jquery.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(".submit_indicator", top.document).css('display','none');
            $("#error_msg", top.document).html('{$sql}');
            $("#error_msg", top.document).css('display','block');
            //setInterval("top.location='../index.php?page=footer';",3000);
        </script>
js;
    }
    else
    {
         echo <<<js
        <script src="{$iniVars['Locations']['siteurl']}js/jquery.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(".submit_indicator", top.document).css('display','none');
            $("#success_msg", top.document).html('{$msg}');
            $("#success_msg", top.document).css('display','block');
            setInterval("top.location='../index.php?page=footer';",3000);
        </script>
js;
    }
    //echo stripslashes($_POST['editor']) ;
?>